package handler

import (
	"gowork/studentGoKit/server/service"
	"gowork/studentGoKit/server/transport"
	httpTransport "github.com/go-kit/kit/transport/http"
	"gowork/studentGoKit/server/endpoint"

	"gowork/studentGoKit/server/util"
	"golang.org/x/time/rate"
)

var stu service.StudentSriImp = service.StudentSriImp{}

func StudentInsert() *httpTransport.Server{
	
	endpInsert := util.RateLimit(rate.NewLimiter(1,3))(endpoint.StudentInsertEnpoint(&stu))
	return httpTransport.NewServer(endpInsert, transport.DecodeStudentInsertOrUpdateRequest, transport.EncodeStudentResponse)
}

func StudentDelete() *httpTransport.Server{

	endpDelete := endpoint.StudentDeleteEnpoint(&stu)
	return httpTransport.NewServer(endpDelete, transport.DecodeStudentDeleteRequest, transport.EncodeStudentResponse)
}

func StudentUpdate() *httpTransport.Server{
	
	endpUpdate := endpoint.StudentUpdateEnpoint(&stu)
	return httpTransport.NewServer(endpUpdate, transport.DecodeStudentInsertOrUpdateRequest, transport.EncodeStudentResponse)
}

func StudentQuery() *httpTransport.Server{
	
	endpQuery := endpoint.StudentQueryEnpoint(&stu)
	return httpTransport.NewServer(endpQuery, transport.DecodeStudentQueryRequest, transport.EncodeStudentResponse)
}

